# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=drone
pkgver=2.20.0
pkgrel=2
pkgdesc="Container-Native, Continuous Delivery Platform"
url="https://drone.io/"
license="Apache-2.0"
arch="all"
pkgusers="drone"
pkggroups="drone"
makedepends="go sqlite-dev"
subpackages="$pkgname-doc $pkgname-openrc"
install="$pkgname.pre-install"
source="https://github.com/harness/gitness/archive/v$pkgver/gitness-$pkgver.tar.gz
	drone.initd
	drone.confd
	drone.conf
	"
# fail now with missing calls in some template
options="net chmod-clean !check"
builddir="$srcdir/gitness-$pkgver"

	# see: https://github.com/harness/drone/blob/master/BUILDING_OSS
export GOFLAGS="$GOFLAGS -tags=libsqlite3,oss,nolimit"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -o bin/drone-server ./cmd/drone-server
}

check() {
	go test ./...
}

package() {
	install -Dm755 bin/drone-server \
		"$pkgdir"/usr/bin/drone-server
	install -Dm 644 LICENSE \
		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE

	install -Dm755 "$srcdir"/drone.initd \
		"$pkgdir"/etc/init.d/drone
	install -Dm644 "$srcdir"/drone.confd \
		"$pkgdir"/etc/conf.d/drone

	install -Dm640 -o drone -g drone "$srcdir"/drone.conf \
		"$pkgdir"/etc/drone.conf
	install -dm755 -o drone -g drone "$pkgdir"/var/lib/drone
}

sha512sums="
5363d249759ac257792852588b3f9672c0b01107732d83382920ff65ed93677bd49d42347ee5242287be2420ecff2d8249fab0ea9a2dbfe71c28c0e2d445f14b  gitness-2.20.0.tar.gz
6f3bf95e6b6bd978c3c2d4951676c89853bae3706098a3e609f296d36cb92c3d68a3390d1bc4b57aaf97f914d25d8d5fa88a32a0410f6d049b947c6978db773d  drone.initd
b2b0d6dbffe987d42292ee0f9c39f8a4e59a62249b62f6bc99369738c17ebe6a699264f13d0e9a4690ebcfd48c4f07637043878f801c1a47fba71f0ef62ca26d  drone.confd
a12f920b568b88a0a813cffcb8dd3dfa2c8e010e5ab0c7b53f07d8084ab68a5bc8b3b11b9fbc2d171d239f5aa775af8240f926472c1aef3c823aea010fd4ad5a  drone.conf
"
